package com.xuedongzhilian.controller;

import com.xuedongzhilian.dto.Result;
import com.xuedongzhilian.service.IRecommendationService;
import com.xuedongzhilian.utils.UserHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 智能推荐控制器
 * </p>
 *
 * @author 学动智联团队
 * @since 2025-10-14
 */
@Slf4j
@RestController
@RequestMapping("/recommendation")
public class RecommendationController {

    @Resource
    private IRecommendationService recommendationService;

    /**
     * 获取学习方案推荐
     */
    @GetMapping("/study")
    public Result getStudyRecommendations() {
        Long userId = UserHolder.getUser().getId();
        return recommendationService.getStudyRecommendations(userId);
    }

    /**
     * 获取运动方案推荐
     */
    @GetMapping("/sport")
    public Result getSportRecommendations() {
        Long userId = UserHolder.getUser().getId();
        return recommendationService.getSportRecommendations(userId);
    }

    /**
     * 获取内容推荐
     */
    @GetMapping("/content")
    public Result getContentRecommendations() {
        Long userId = UserHolder.getUser().getId();
        return recommendationService.getContentRecommendations(userId);
    }

    /**
     * 获取所有推荐
     */
    @GetMapping("/all")
    public Result getAllRecommendations() {
        Long userId = UserHolder.getUser().getId();
        
        // 获取学习推荐
        Result studyResult = recommendationService.getStudyRecommendations(userId);
        
        // 获取运动推荐
        Result sportResult = recommendationService.getSportRecommendations(userId);
        
        // 获取内容推荐
        Result contentResult = recommendationService.getContentRecommendations(userId);
        
        // 组合结果
        new java.util.HashMap<String, Object>() {{
            put("study", studyResult);
            put("sport", sportResult);
            put("content", contentResult);
        }};
        
        return Result.ok(new java.util.HashMap<String, Object>() {{
            put("study", studyResult);
            put("sport", sportResult);
            put("content", contentResult);
        }});
    }
}